const express = require('express');
const app = express();

require('express-async-errors');
require('dotenv').config();
const errCaptureMiddleware = require('./middleware/err-capture');

app.use(express.json());

const sendEmail = require('./controlers/send-email');
app.get('/send', sendEmail);

const notFoundMD = require('./middleware/not-found');
app.use(notFoundMD); // 匹配其他未定义

app.use(errCaptureMiddleware); // 全局错误捕获

app.listen(8080, () => {
   console.log('Server is running on port 8080');
});